﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CaltechSoft.Service.EntityFW.Entity
{
    public class Certificate : BaseEntity
    {
        [Key]
        public int CertificateId { get; set; }
        public string CertificateNo { get; set; }
        public string WorkOrderNo { get; set; }
        public int CustomerId { get; set; }
        public int EquipmentId { get; set; }
        public string ConditionReceivedId { get; set; }
        public string ConditionReturnedId { get; set; }
        public string Temperature { get; set; }
        public string RelativeHumidity { get; set; }
        public string CalibrationCycle { get; set; }
        public DateTime? CalibrationDate { get; set; }
        public DateTime? NextDueDate { get; set; }
        public string CertifiedBy { get; set; }
        public string Technician { get; set; }
        public string ApprovedBy { get; set; }
        public string QualityInspector { get; set; }


        //Extra field
        public string Manufacturer { get; set; }
        public string Description { get; set; }
        public string ModelNumber { get; set; }
        public string SerialNumber { get; set; }
        public string PONumber { get; set; }
        public string Procedure { get; set; }
        public string AssetNumber { get; set; }
        public string Remarks { get; set; }



        public IList<CertificateDetails> CertificateDetails { get; set; }
    }

    public class CertificateMap : EntityTypeConfiguration<Certificate>
    {
        public CertificateMap()
        {
            this.HasKey(t => t.CertificateId);
            this.Property(t => t.CertificateId).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
            this.ToTable("Certificate");
            this.HasMany(x => x.CertificateDetails).WithRequired(x => x.Certificate).HasForeignKey(x => x.CertificateId);
        }
    }
}
